import { message } from 'ant-design-vue'
import 'ant-design-vue/lib/message/style'

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export default function NotificationPlugin(editor) {
  const Notification = editor.plugins.get('Notification')

  Notification.on(
    'show',
    (evt, data) => {
      // 暂仅处理 warning
      if (data.type === 'warning') {
        message.warn(data.message)
      }

      // 停止此事件以防止出现 alert
      evt.stop()
    },
    { priority: 'low' }
  )
}
